﻿using UnityEngine;
using Cysharp.Threading.Tasks;
namespace Client.Base
{
    public class FsmDownloadPackageFiles : PatchState
    {
        public override async void OnEnter()
        {
            this.Log("[Patch] FsmDownloadPackageFiles.");
            var downloaders = PatchHandle.Instance.GetDownloaders();
            for (int i = 0; i < downloaders.Count; i++)
            {
                var downloader = downloaders[i];
                downloader.DownloadErrorCallback = PatchHandle.Instance.DownloadErrorCallback;
                downloader.DownloadUpdateCallback = PatchHandle.Instance.DownloadUpdateCallback;
                downloader.BeginDownload();
                await downloader.ToUniTask();
            }

            PatchHandle.Instance.Change<FsmDownloadPackageOver>();

        }

    }
}
